import { createRouter, createWebHashHistory } from 'vue-router'
import LayoutView from '../layout/LayoutView.vue'
//import LoginManageView from '../components/common/LoginViews.vue';


const routes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true   // 当设置 true 的时候该路由不会在侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    name: 'Dashboard',
     meta: {roles: ['admin','editor'], title: '主界面', icon: 'dashboard' },
    // enName: 'Project',
    component: LayoutView,
    redirect: '/dashboard',
    children:[
     {
      path: '/dashboard',
      component: () => import('@/views/dashboard/index'),
      //  meta: {roles: ['admin','editor'], title: '主界面2', icon: 'dashboard' }
     },
     {
      path: '/electromagneticFlowmeter',
      component: () => import('@/views/electromagneticFlowmeter/index'),
      meta: {roles: ['admin','editor'], title: '电磁流量计',title_en:'Electromagnetic Flowmeter' , icon:'dashboard'}
     },
     {
      path: '/metalRotameter',
      component: () => import('@/views/metalRotameter/index'),
      meta: { roles: ['admin','editor'],title: '金属转子流量计',title_en:'Metal Rotameter' , icon:'dashboard'}
     },
     {
      path: '/turbineFlowmeter',
      component: () => import('@/views/turbineFlowmeter/index'),
      meta: {roles: ['admin','editor'],  title: '涡轮流量计',title_en:'Turbine Flowmeter' , icon:'dashboard'}
     },
     {
      path: '/vortexFlowmeter',
      component: () => import('@/views/vortexFlowmeter/index'),
      meta: {roles: ['admin','editor'], title: '涡街流量计',title_en:'Vortex Flowmeter' , icon:'dashboard'}
     },
     {
      path: '/coriolisMassFlowmeter',
      component: () => import('@/views/coriolisMassFlowmeter/index'),
      meta: {roles: ['admin','editor'], title: '科里奥利质量流量计',title_en:'Coriolis Mass Flowmeter' , icon:'dashboard'}
     },
     {
      path: '/orificePlateFlowmeter',
      component: () => import('@/views/orificePlateFlowmeter/index'),
      meta: { roles: ['admin','editor'],title: '孔板流量计',title_en:'Orifice Plate Flowmeter' , icon:'dashboard'}
     },
     {
      
        path: '/about',
        name: 'about',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
      
     }]
  },
  // {
  //   path: '/about',
  //   name: 'about',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  // }

   // 404 page must be placed at the end !!!
   { 
    path:'/:pathMatch(.*)',
    component: () => import('@/views/404'),
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}
export default router
